<template>
    <div>
        <!-- <h3>当前最新的count值为：{{$store.state.count}}</h3> -->
        {{$store.getters.showNum}}

        <button @click="addCount()">+1</button>
        <button @click="addCountAsyn()">+1Asyn</button>
        <button @click="addCountNAsyn()">+NAsyn</button>
    </div>
</template>
<script>
export default {
    name:"AddAction",
    data(){
        return{

        }
    },
    methods:{
        addCount(){
            // 1.直接访问，PS:不合法的访问方法
            // this.$store.state.count++;

            // 2.mutation访问
            // this.$store.commit('add')

            // 3.带参访问
            this.$store.commit('addN', 3);

            // this.$store.
        },
        addCountAsyn(){
            // dispatch触发action
            // commit触发mutation
            this.$store.dispatch('addAsync')
        },
        addCountNAsyn(){
            // 带参异步访问
             this.$store.dispatch('addNSync', 3)
        }
    }
    
}
</script>